@echo off
REM Windows开发环境启动脚本
echo ====================================
echo 在线学习平台 - 开发环境启动脚本
echo ====================================

REM 检查是否设置了JWT_SECRET
if not defined JWT_SECRET (
    echo [错误] 请先设置JWT_SECRET环境变量:
    echo set "JWT_SECRET=your-super-secret-jwt-key-that-must-be-at-least-64-characters-long"
    pause
    exit /b 1
)

echo [信息] 环境变量检查通过
echo.

echo [提示] 请确保MySQL服务已启动并运行在3306端口
echo [提示] 数据库: learning, 用户: learning, 密码: learning123
echo.

echo 请选择要启动的服务:
echo 1. 仅启动后端 (端口8080)
echo 2. 仅启动前端 (端口5173)
echo 3. 仅启动AI服务 (端口8000)
echo 4. 全部启动 (打开3个新窗口)
echo 5. 退出

set /p choice="请输入选择 (1-5): "

if "%choice%"=="1" goto backend
if "%choice%"=="2" goto frontend
if "%choice%"=="3" goto ai
if "%choice%"=="4" goto all
if "%choice%"=="5" goto exit

echo 无效选择，退出
goto exit

:backend
echo [启动] 后端服务...
cd backend
start "后端服务" cmd /k "mvnw.cmd spring-boot:run"
goto exit

:frontend
echo [启动] 前端服务...
cd frontend
start "前端服务" cmd /k "npm run dev"
goto exit

:ai
echo [启动] AI服务...
cd ai
start "AI服务" cmd /k "python main.py"
goto exit

:all
echo [启动] 所有服务...
echo.
echo 正在启动后端服务...
cd backend
start "后端服务 (端口8080)" cmd /k "echo [后端] 启动中... && mvnw.cmd spring-boot:run"
cd ..

echo 正在启动前端服务...
cd frontend
start "前端服务 (端口5173)" cmd /k "echo [前端] 启动中... && npm run dev"
cd ..

echo 正在启动AI服务...
cd ai
start "AI服务 (端口8000)" cmd /k "echo [AI] 启动中... && python main.py"
cd ..

echo.
echo [完成] 所有服务启动命令已执行
echo.
echo 服务地址:
echo - 前端: http://localhost:5173
echo - 后端API: http://localhost:8080/api/v1/health
echo - AI服务: http://localhost:8000/health
echo.

:exit
pause





